<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function *gen(arg){
      console.log(arg);
      let one = yield 111;
      console.log(one);
      let two = yield 222;
      console.log(two);
      yield 333;
    }

    // 执行获取迭代器对象
    let iterator = gen('AAA');
    console.log(iterator.next());
    // next方法可以传入实参
    console.log(iterator.next('bbb'));
    console.log(iterator.next('ccc'));
    console.log(iterator.next());
    
  </script>
</body>
</html>